package com.example.vo;

/**
 * @Description:
 * @Author: aimi
 * @Create: 2024-05-17
 **/
public class IdHolder {
    private static final ThreadLocal<Long> threadLocal =  new ThreadLocal<>();

    private static final ThreadLocal<Long> storeIdThreadLocal = new ThreadLocal<>();

    public static void setUserId(Long id){
        threadLocal.set(id);
    }

    public static Long getUserId(){
        return threadLocal.get();
    }

    public static void setStoreId(Long id){
        storeIdThreadLocal.set(id);
    }

    public static Long getStoreId(){
        return storeIdThreadLocal.get();
    }

    //移除ThreadLocal对象
    public static void removeThreadLocal(){
        threadLocal.remove();
        storeIdThreadLocal.remove();
    }
}